/**
 * Created by wys on 2016/8/22.
 */
$(function(){

    var beforeScroll=$(document).scrollTop();

    $(window).scroll(function(){
        //�жϹ�������    +:����   -:����
        var direction=$(this).scrollTop();
        var flagDirection=direction-beforeScroll;

        if(flagDirection>0){
            //����
            $('#linkTop').css({
                'top':"3769px"
            })
        }else{
            //����
            var needHeight=$(this).height()+$(this).scrollTop()-48+'px';
            if(parseInt(needHeight)<3769){
                $('#linkTop').css({
                    'top':needHeight
                })
            }
        }
        beforeScroll=$(this).scrollTop();
    })

    //�ص�����
    $('#linkTop').click(function(){
        $(document).scrollTop(0);
    })

    //�ֲ���
        //�Զ���
    var flagDirection='r';
    var indexTop=0;
    var timer=null;
    if(timer){
        clearInterval(timer);
    }
    timer=setInterval(runImage,3000);
    function runImage(){
        if(flagDirection=='r'){
            indexTop++;
            indexTop=indexTop%9;
        }else if(flagDirection=='l'){
            indexTop--;
            if(indexTop==-1){
                indexTop=8;
            }
        }
        $('#wxs_top').css({
            background:'url("images/photo_7_7_11'+indexTop+'.jpg") no-repeat 0 0'
        });

        $('#wxs_top .tb .b li').eq(indexTop).addClass('active')
        .siblings().removeClass('active');

    }
        //�ֶ���ť����
    $('#wxs_top .tb .carousel .next').click(function(){
        if(timer){
            clearInterval(timer);
        }
        flagDirection='r';
        runImage();
        timer=setInterval(runImage,3000);

    })
    $('#wxs_top .tb .carousel .prev').click(function(){
        if(timer){
            clearInterval(timer);
        }
        flagDirection='l';
        runImage();
        timer=setInterval(runImage,3000);
    })

    //图标旋转  Begin
    var iconTrans=null;
    var deg=0;
    $('.other').mouseover(function(){
        iconTrans=setInterval(function(){
            deg=deg+100;
            $('.other >img').css({
                transform:"rotate("+deg+"deg)"
            })
        },10);
    })
    $('.other').mouseout(function(){
       clearInterval(iconTrans);
        $('.other >img').css({
            transform:"rotate("+0+"deg)"
        })
    })
    //图标旋转  End

    //图片层 Begin
    $('li').mouseover(function(){
        $(this).children('.limit').css('display','block');
    })
    $('li').mouseout(function(){
        $(this).children('.limit').css('display','none');
    })
    //图片层 End

})

